import 'package:flutter/material.dart';
import 'package:flutter_sample/stock/ui_stock_home.dart';
import 'package:flutter_sample/tab/ui/home/ui_tab_home.dart';
import 'package:flutter_sample/vo_home_item.dart';

class UIHome extends StatelessWidget {
  const UIHome({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final List<HomeItemVO> data = [
      HomeItemVO("Button", () {}),
      HomeItemVO("List", () {}),
      HomeItemVO("Http", () {}),
      HomeItemVO("Tab", () {
        Navigator.push(
          context,
          MaterialPageRoute(builder: (context) => UITabHome()),
        );
      }),
      HomeItemVO("Stock", () {
        Navigator.push(
          context,
          MaterialPageRoute(builder: (context) => const UIStockHome()),
        );
      }),
    ];

    return Scaffold(
      body: SafeArea(
        top: true,
        child: Wrap(
            children: List.generate(data.length, (index) => generateButton(data[index]))
        ),
      )
    );
  }

  Widget generateButton(HomeItemVO vo) => TextButton(
    onPressed: vo.onPressed,
    child: Text(vo.name),
  );
}
